package test;


import implementation.search.AbstractOrderedArray;
import implementation.search.BinaryOrderedArray;
import implementation.search.InterpolateOrderedArray;

import java.util.ArrayList;
import java.util.List;

public class Report6 {

    public static void main(String[] args) {
        BinaryOrderedArray binaryArray = new BinaryOrderedArray();
        InterpolateOrderedArray interpolateArray = new InterpolateOrderedArray();
        List<Integer> nList = getNList();

        int j = 0;

        for (int n : nList) {
            binaryArray.clear();
            interpolateArray.clear();
            for (int k = 0; k < n; k++) {
                j = (int) (Math.random() * n);
                binaryArray.put(j, k);
                interpolateArray.put(j, k);
            }

           System.out.println("\nN = " + n);
           System.out.println("\tBinary: ");
           printReport(binaryArray, n);
           System.out.println("\tInterpolate: ");
           printReport(interpolateArray, n); 
        }
    }

    private static void printReport(AbstractOrderedArray array, int n) {
        long t0 = System.currentTimeMillis();
        for (int i = 0; i < n; i++) {
            int h = (int)(Math.random()*(n*2));
            array.get(h);
            /*System.out.print(h+" : ");
            System.out.print(array.get(h) + " - ");*/
        }
        long tf = System.currentTimeMillis();
        System.out.println("\n\t\tTime : " + (tf - t0));
    }

    public static List<Integer> getNList() {
        ArrayList<Integer> nList = new ArrayList<Integer>();
       /* nList.add(50);
        nList.add(100);
        nList.add(150);
        nList.add(200);*/
        nList.add(50000);
        nList.add(100000);
        nList.add(150000);
        nList.add(200000);
        return nList;
    }
}
